import '../../public.dart';

class TopGiftCardsPage extends StatelessWidget {
  const TopGiftCardsPage({super.key});

  // Mock data request function for pagination
  Future<List<CategoryTopQuoteDetailDto>> _fetchGiftCards(
    int page,
    int pageSize,
  ) async {
    final response = await SellCardApi.queryTopCategory();
    return response.content ?? [];
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey.shade50,
      appBar: AppBar(title: const Text('Top Gift Cards')),
      body: Pagination<CategoryTopQuoteDetailDto>(
        request: _fetchGiftCards,
        itemBuilder: (context, giftCard) =>
            _buildGiftCardItem(context, giftCard),
      ),
    );
  }

  Widget _buildGiftCardItem(
    BuildContext context,
    CategoryTopQuoteDetailDto giftCard,
  ) {
    return InkWell(
      onTap: () {},
      child: Container(
        margin: const EdgeInsets.only(bottom: 16, left: 16, right: 16),
        padding: const EdgeInsets.all(16),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(8),
          boxShadow: [
            BoxShadow(
              color: Colors.grey.withValues(alpha: .1),
              spreadRadius: 1,
              blurRadius: 3,
              offset: const Offset(0, 2),
            ),
          ],
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    giftCard.cardType ?? '',
                    style: const TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.bold,
                      color: Colors.black87,
                    ),
                  ),
                  const SizedBox(height: 4),
                  Text(
                    giftCard.cardCategory ?? '',
                    style: TextStyle(fontSize: 14, color: Colors.grey.shade600),
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                ],
              ),
            ),
            Text(
              '₦${giftCard.quote ?? ''}',
              style: const TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.bold,
                color: Color(0xFF000000),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
